#include "evdictbase.h"
#include "soundex.h"
#include "evdictCUI.h"
#include "evdictutil.h"
#include <conio.h>
#include <string.h>
#include <iostream>
using namespace std;

int main()
{
	char* word;
	char* hashCode;
	int address = NOT_FOUND;
	WordDefinition theWordDefinition;
	
	loadData(DICTIONARY_INDEX_FILE,DICTIONARY_BACKUP_FILE);
	showLayoutScreen();
	showContextMenu();

	while(1)
	{
		showLayoutScreen();
		word = enterWord();
		_strlwr(word);
		hashCode = soundex(word);
		address = getWordAddress(word, hashCode);
		if (address == (NOT_FOUND))
		{
			showMessage("Tu ban vua nhap chua co. Ban co the them tu nay bang cach an phim T");
		}
		else
		{

			theWordDefinition = getWordDefinitionByAddress(DICTIONARY_DATA_FILE, address);
			showWordDefinition(theWordDefinition);
			gotoxy(5, 8);
			//cout << "Dia chi cua tu can tra la: " << address;
		}
		showContextMenu(address, word, hashCode);
	}

	_getch();
	return 0;
}